<?php
include_once('admin.inc.php');
$feeModel = new Model('feedback');
$do = get_param('do');
switch($do){
	default:
	case 'feedbacks':
		$list = $feeModel->order('id DESC')->get();
		$smarty->assign('list', $list);
		$smarty->display('admin/feedbacks.html');
	break;
	case 'delFeedback':
		$id = (int)get_param('id');
		if( empty($id) ){
			ajax_return(array('status'=>'failed', 'info'=>'删除失败,非法id.'));
			//msg('非法id',-1);
			exit;
		}
		if( $feeModel->where("id=$id")->del() ){
			ajax_return(array('status'=>'success', 'info'=>'删除成功'));
		}else{
			ajax_return(array('status'=>'failed', 'info'=>'删除失败'));
		}

	break;
	case 'status':
		$id = (int)get_param('id');
		$status = get_param('status');
		if( empty($id) ){
			msg('非法id',-1);
			exit;
		}
		$rs = $feeModel->where("id=$id")->value(array('status'=>$status))->update();
		if( $rs ){
			echo 1;
		}else{
			echo 0;
		}
	break;
}
